package com.spring.housing.controller.commen;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.netflix.client.http.HttpRequest;
import com.spring.housing.acceptType.PageParams;
import com.spring.housing.returnType.CommenResult;
import com.spring.housing.service.Login.LoginServer;
import com.spring.housing.util.FileUpload;
import com.spring.housing.util.QueryTemplateForJdbc;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Slf4j
@RestController
@RefreshScope
public class ControlController {
    @Value("${delivery.port}")
    private  String dPort;
    @Autowired
    LoginServer loginServer;
    @Autowired
    QueryTemplateForJdbc queryTemplateForJdbc;
    @Value("${file.upload.path}")
    private  String filePath;
    @Value("${ribbon.ReadTimeout}")
    String res;
//    @SentinelResource(value = "testHotKey",blockHandler = "deal_testHotKey")
    @PostMapping("/login/index")
    public CommenResult login (@RequestBody PageParams params){
        return loginServer.logincheck(params);
    }

    @PostMapping("/home/location/arr")
    public CommenResult locationArr (){
        return loginServer.locationArr();
    }


    @PostMapping("/getUserInfo")
    public CommenResult message (){
        return loginServer.getmessageCount();
    }
    @PostMapping("/test")
    public String logintest (){
        return      loginServer.logincheck2();
    }
    @PostMapping("/home/ddcx")
    public CommenResult ddcx (@RequestBody PageParams params) throws Exception {
        return loginServer.getddcx(params,dPort);
    }
    @PostMapping("/home/xxzz/querymessage")
    public CommenResult querymessage (@RequestBody PageParams params) {
        return loginServer.getmessage(params);
    }
    @PostMapping("/getLocations")
    public CommenResult getLocations () {
        return loginServer.getLocations();
    }

    @PostMapping("/sendMessage")
    public CommenResult sendMessage (@RequestBody PageParams page)  {
        return loginServer.sendMessage(page);
    }


    @PostMapping("/ofckb/subOrder")
    public CommenResult ofckbSubOrder (@RequestBody PageParams page)  {
        return loginServer.ofckbSubOrder(page);
    }
    @PostMapping("/ofckb/acceptOder")
    public CommenResult acceptOder (@RequestBody PageParams page)  {
        return loginServer.acceptOder(page);
    }
//用户处理中心的查询，不受定位影响
    @PostMapping("/clzx/queryClzx")
    public CommenResult queryClzx (@RequestBody PageParams page)  {
        return loginServer.queryClzx(page);
    }

    //处理订单
    @PostMapping("/clzx/handelClzx")
    public CommenResult handelClzx (@RequestBody PageParams page)  {
        return loginServer.handelClzx(page);
    }



    @PostMapping("/test3")
    public CommenResult logintest3 (MultipartFile file) throws IOException {
        return FileUpload.upload(file,filePath);
    }






}
